/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EnigmaUtils;
import java.io.*;


/**
 *
 * @author snowangelic
 */
public class FileCopier {
    public static void copyFile( File source, File destination ){ //Methode permettant la copie d'un fichier
        // Declaration des flux
        java.io.FileInputStream sourceFile=null;
        java.io.FileOutputStream destinationFile=null;
        try {
            // Création du fichier :
            destination.createNewFile();
            // Ouverture des flux
            sourceFile = new java.io.FileInputStream(source);
            destinationFile = new java.io.FileOutputStream(destination);
            // Lecture par segment de 0.5Mo
            byte buffer[]=new byte[512*1024];
            int nbLecture;
            while( (nbLecture = sourceFile.read(buffer)) != -1 ) {
                destinationFile.write(buffer, 0, nbLecture);
            }
        }
        catch(Exception e){
            System.out.println(e.toString());
        }
     }
}
